package ch.zbw.pra.sysventory.domain.visualisation;

import java.util.ArrayList;
import java.util.List;

import ch.zbw.pra.sysventory.domain.model.Computer;

public class VisuControllComputer extends AVisuControll implements IVisuControll<Computer> {

	private boolean hostName;
	private boolean sid;
	private boolean computerTyp;
	private boolean ram;

	public VisuControllComputer() {
		super();
	}

	public boolean isHostName() {
		return this.hostName;
	}

	public void setHostName(boolean hostName) {
		this.hostName = hostName;
		updateObserver();
	}

	public boolean isSid() {
		return this.sid;
	}

	public void setSid(boolean sid) {
		this.sid = sid;
		updateObserver();
	}

	public boolean isComputerTyp() {
		return this.computerTyp;
	}

	public void setComputerTyp(boolean computerTyp) {
		this.computerTyp = computerTyp;
		updateObserver();
	}

	public boolean isRam() {
		return this.ram;
	}

	public void setRam(boolean ram) {
		this.ram = ram;
		updateObserver();
	}

	public void addDataToRow(List<Computer> data, List<List<String>> row) {
		if (isHostName()) {
			row.add(makeHostnameList(data));
		}
		if (isSid()) {
			row.add(makeSidComputerList(data));
		}
		if (isComputerTyp()) {
			row.add(makeTypeComputerList(data));
		}
		if (isRam()) {
			row.add(makeRamComputerList(data));
		}
	}

	public void addDataToColumn(List<String> data) {
		if (isHostName()) {
			data.add("Hostname");
		}
		if (isSid()) {
			data.add("SID");
		}
		if (isComputerTyp()) {
			data.add("Computertyp");
		}
		if (isRam()) {
			data.add("RAM in MB");
		}
	}

	private List<String> makeHostnameList(List<Computer> computers) {
		List<String> data = new ArrayList<String>();
		for (Computer comp : computers) {
			data.add(comp.getHostNameComputer());
		}
		return data;
	}

	private List<String> makeSidComputerList(List<Computer> computers) {
		List<String> data = new ArrayList<String>();
		for (Computer comp : computers) {
			data.add(comp.getSidComputer());
		}
		return data;
	}

	private List<String> makeTypeComputerList(List<Computer> computers) {
		List<String> data = new ArrayList<String>();
		for (Computer comp : computers) {
			data.add(comp.getTypeComputer());
		}
		return data;
	}

	private List<String> makeRamComputerList(List<Computer> computers) {
		List<String> data = new ArrayList<String>();
		for (Computer comp : computers) {
			data.add(comp.getRamComputer());
		}
		return data;
	}

	public void restoreTo(boolean value) {
		this.hostName = value;
		this.sid = value;
		this.computerTyp = value;
		this.ram = value;
	}

}
